package org.example.ba01;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Component 表示创建对象，对象放在容器中。作用是：<bean>
 *     属性：value,表示对象的名称，也就是<bean>的id属性
 *     和@Component功能相同的创建对象的注解
 *     1）@Repository:放在dao接口的实现类上，表示创建dao对象
 *     2）@Service:放在业务层接口的实现类上，表示业务层对象，业务层对象有事务功能
 *     3）@Controller:放在控制器类上面，表示创建控制器对象，属于表示层对象
 */
@Component("student")
public class Student {
    /*@Value("小何同学")*/
    @Value("${myName}")
    private String name;
    /*@Value("27")*/
    @Value("${myAge}")
    private int age;

    private School school;

    public Student(){

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public School getSchool() {
        return school;
    }

    @Autowired
    /* @Qualifier(value = "school")*/
    /* @Resource*/

    public void setSchool(School school) {
        this.school = school;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", school=" + school +
                '}';
    }
}
